textview: optimize linedisplay cache based on number of visible rows
authorChristian Hergert <chergert@redhat.com>
Thu, 5 Sep 2019 23:45:49 +0000 (16:45 -0700)
committerChristian Hergert <chergert@redhat.com>
Fri, 6 Sep 2019 02:06:35 +0000 (19:06 -0700)
commit5e49da1d73534e45e3139d7ded740f3115b7096f
treeb02be74afdbf81f4c7ddb398a929224b9e9673b8
parenta29853f53bba38a6657530aed8491630326b034e
textview: optimize linedisplay cache based on number of visible rows

This tries to estimate the number of visible rows in a textview based on
the default text size and then tunes the GtkTextLineDisplayCache to keep
3*n_rows entries in the cache.

This was found imperically to be near the right cache size. In most cases,
this is less than the number of items we cache now. However, in some cases,
such as the "overview map" from GtkSourceView, it allows us to reach a
higher value such as 1000+. This is needed to keep scrolling smooth on
the larger view sizes.

With this patch, a HiDPI system with a GtkSourceView and GtkSourceMap
from the GTK 4 port can perform smooth scrolling simultaneously.
gtk/gtktextlayout.c
gtk/gtktextlayoutprivate.h
gtk/gtktextlinedisplaycache.c
gtk/gtktextlinedisplaycacheprivate.h
gtk/gtktextview.c